import React, {Fragment, useState} from 'react';
import AddUser from "./components/Users/AddUser.component";
import UsersList from "./components/Users/UsersList.component";

function App() {
    const [usersList, setUsersList] = useState([]);

    const addUserHandler = (uName, uAge) => {
        setUsersList((prevState) => {
            return [...prevState, { name: uName, age: uAge }];
        });
    };

    return (
    <Fragment>
      <AddUser onAddUser={addUserHandler} />
      <UsersList users={usersList}/>
    </Fragment>
    );
}

export default App;
